home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------
- #
- # GDeviceUtils.h
- #
- # by Eric Traut
- #
- ------------------------------------------------------------------------------*/
-
- #include <Types.h>
- #include <QDOffscreen.h>
- #include <Displays.h>
-
- // GraphicSurface
- // This class encapsulates a blitting surface, specifying
- // its base pointer, depth, dimensions and rowBytes values.
- // The actual surface may be real or virtual. In many ways,
- // it's comparable to a GWorld in the Mac toolbox.
- class GraphicSurface
- {
- public:
- GraphicSurface();
-
- void
- ExtractRealDeviceInfo(
- GDHandle inGDevice);
-
- UInt16
- GetRowBytes() const
- {
- return mRowBytes;
- }
-
- UInt8 *
- GetPixelDataPtr() const
- {
- return mPixelData;
- }
-
- UInt16
- GetBitDepth() const
- {
- return mBitDepth;
- }
-
- UInt16
- GetHeight() const
- {
- return mHeight;
- }
-
- UInt16
- GetWidth() const
- {
- return mWidth;
- }
-
- UInt32
- GetBackingSize() const
- {
- // Allocate two extra scan lines for some slop
- return GetRowBytes() * (GetHeight() + 2);
- }
-
- private:
- UInt16 mRowBytes;
- UInt8 * mPixelData;
- UInt16 mBitDepth;
- UInt16 mHeight;
- UInt16 mWidth;
- };
-
-
- class VirtualGDevice;
-
- class GraphicBlendEffect
- {
- public:
- GraphicBlendEffect()
- {
- }
-
- virtual
- ~GraphicBlendEffect()
- {
- }
-
- virtual Boolean
- Initialize()
- {
- return true;
- }
-
- virtual void
- SetEffectValue(
- UInt16 inValueIndex,
- double inValue)
- {
- (void)inValueIndex;
- (void)inValue;
- }
-
- virtual void
- BlendVirtualDevices(
- const GraphicSurface & inDestSurface,
- VirtualGDevice ** inVDeviceList,
- UInt32 inVDeviceCount) = 0;
- };
-
-
- class SimpleBlendEffect : public GraphicBlendEffect
- {
- public:
- SimpleBlendEffect()
- {
- }
-
- virtual void
- BlendVirtualDevices(
- const GraphicSurface & inDestSurface,
- VirtualGDevice ** inVDeviceList,
- UInt32 inVDeviceCount);
- };
-
-
- class ThrobEffect : public GraphicBlendEffect
- {
- public:
- ThrobEffect()
- {
- }
-
- UInt16 *
- DimVariably(
- UInt16 *in,
- UInt16 *out,
- int ratio,
- int count,
- int start,
- int stop);
-
- virtual void
- BlendVirtualDevices(
- const GraphicSurface & inDestSurface,
- VirtualGDevice ** inVDeviceList,
- UInt32 inVDeviceCount);
- };
-
-
- class DontThrobEffect : public GraphicBlendEffect
- {
- public:
- DontThrobEffect()
- {
- mPrimaryScreenFraction = 0.0;
- }
-
- UInt16 *
- DimVariably(
- UInt16 *in,
- UInt16 *out,
- int ratio,
- int count,
- int start,
- int stop);
-
- virtual void
- BlendVirtualDevices(
- const GraphicSurface & inDestSurface,
- VirtualGDevice ** inVDeviceList,
- UInt32 inVDeviceCount);
-
- virtual void
- SetEffectValue(
- UInt16 inValueIndex,
- double inValue);
-
- private:
- double mPrimaryScreenFraction;
- };
-
-
- // CapturedGDevice
- // This class allows us to "capture" an existing GDevice (monitor).
- class CapturedGDevice
- {
- public:
- CapturedGDevice();
-
- virtual
- ~CapturedGDevice();
-
- void
- CaptureDevice(
- GDHandle inGDevice,
- VirtualGDevice ** inVDeviceList,
- UInt32 inVDeviceCount);
-
- void
- UncaptureDevice();
-
- void
- UpdateCapturedScreen();
-
- void
- RecomputeGDHandle();
-
- GraphicSurface &
- GetGraphicSurface()
- {
- return mCapturedSurface;
- }
-
- void
- SetGraphicBlendEffect(
- GraphicBlendEffect * inBlendEffect);
-
- void
- SetGraphicBlendValue(
- UInt32 inValueIndex,
- double inValue);
-
- void
- SetPixelBase(
- UInt8 * inPixelBase);
-
- PixMapHandle
- GetPixMapHandle()
- {
- return mGDHandle[0]->gdPMap;
- }
-
- void
- ClearCapturedScreen();
-
- private:
- GraphicBlendEffect * mBlendEffect;
-
- GraphicSurface mCapturedSurface;
- GDHandle mGDHandle;
- DisplayIDType mDisplayID;
- Boolean mDeviceCaptured;
-
- VirtualGDevice ** mVirtualDeviceList;
- UInt32 mVirtualDeviceCount;
- };
-
-
- // VirtualGDevice
- // This class allows us to create a new "virtual" GDevice, effectively
- // adding a monitor to the system. One VirtualGDevice (and one only)
- // should be designated the "primary" device. This allows us to make
- // use of the existing GWorld handle in the system.
- class VirtualGDevice
- {
- public:
- VirtualGDevice();
-
- virtual
- ~VirtualGDevice();
-
- Boolean
- Initialize(
- CapturedGDevice & inRealGDevice,
- UInt32 inIndex);
-
- void
- GetPreferredPosition(
- Rect & outPos)
- {
- outPos = mPreferredPos;
- }
-
- void
- Uninitialize();
-
- void
- RecomputeGDHandle();
-
- GraphicSurface &
- GetGraphicSurface()
- {
- return mVirtualSurface;
- }
-
- GDHandle
- GetGDHandle()
- {
- RecomputeGDHandle();
- return mGDHandle;
- }
-
- private:
- GraphicSurface mVirtualSurface;
- Ptr mDeviceBacking;
- Boolean mAddedToDeviceList;
- GDHandle mGDHandle;
- DisplayIDType mDisplayID;
- Rect mPreferredPos;
- };
-
-
-
-
-
-
-